package com.xxx.meter.model.http;

import com.xxx.meter.model.http.bean.MachineChildBean;
import com.xxx.meter.model.http.bean.MachineInfoBean;
import com.xxx.meter.model.http.bean.MachineRecordBean;
import com.xxx.meter.model.http.bean.MachineSwitchBean;
import com.xxx.meter.model.http.bean.MachineTypeBean;
import com.xxx.meter.model.http.bean.PatrolBean;
import com.xxx.meter.model.http.bean.PatrolRecordDetailBean;
import com.xxx.meter.model.http.bean.PatrolRecordListBean;
import com.xxx.meter.model.http.bean.SubmitBean;
import com.xxx.meter.model.http.bean.WorkInfoBean;
import com.xxx.meter.model.http.bean.base.BaseBean;
import com.xxx.meter.model.http.bean.base.BooleanBean;
import com.xxx.meter.model.http.bean.base.PageBean;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface ApiService {

    //获取设备类型集合
    @GET("webapp/web_equipmentgroups")
    Observable<BaseBean<PageBean<MachineTypeBean>>> getDeviceTypeList();

    //获取全部设备列表
    @GET("webapp/selectEquipments")
    Observable<BaseBean<List<MachineChildBean>>> getAllDeviceList();

    //扫描设备
    @GET("webapp/web_equipmentscancodes")
    Observable<BaseBean<MachineChildBean>> sweepDevice(
            @Query("equipmentcode") String sweepCode,
            @Query("equipmentcodetype") String sweepType
    );

    //获取抄表信息列表
    @GET("webapp/web_inspectionitems")
    Observable<BaseBean<List<MachineInfoBean>>> getMeterDeviceInfoList(
            @Query("equipmenttypekey") String deviceType,
            @Query("equipmentkey") String deviceId
    );

    //获取训机信息列表
    @GET("webapp/xc_inspectionitems")
    Observable<BaseBean<List<PatrolBean>>> getPatrolDeviceInfoList(
            @Query("equipmenttypekey") String deviceType,
            @Query("equipmentkey") String deviceId
    );

    //获取验证数据
    @GET("webapp/getUsers")
    Observable<BaseBean<List<SubmitBean>>> getValidationData();

    //提交抄表
    @POST("webapp/saveAll")
    @FormUrlEncoded
    Observable<BaseBean<BooleanBean>> submitMeterInfo(
            @Field("json") String json
    );

    //提交训机
    @POST("webapp/saveAlls")
    @FormUrlEncoded
    Observable<BaseBean<BooleanBean>> submitPatrolInfo(
            @Field("json") String json
    );

    //获取设备的上次开关机时间
    @GET("webapp/getOpenTime")
    Observable<BaseBean<MachineSwitchBean>> getMachineSwitch(
            @Query("equipmenttypekey") String deviceType,
            @Query("equipmentkey") String deviceId
    );

    //提交开关机时间
    @POST("webapp/batchInsertTime")
    @FormUrlEncoded
    Observable<BaseBean<BooleanBean>> submitMachineSwitch(
            @Field("json") String json
    );

    //获取信息设备信息列表
    @GET("webapp/inspectionitems")
    Observable<BaseBean<List<MachineInfoBean>>> getInfoDeviceInfoList(
            @Query("recordId") String recordId,
            @Query("equipmenttypekey") String deviceType,
            @Query("equipmentkey") String deviceId
    );

    //获取抄表记录列表
    @GET("webapp/getInspectionrecords")
    Observable<BaseBean<PageBean<MachineRecordBean>>> getMachineRecordList(
            @Query("startTime") long startTime,
            @Query("endTime") long endTime,
            @Query("equipmenttypekey") String deviceType,
            @Query("equipmentkey") String deviceId,
            @Query("pageNum") int pageNum,
            @Query("pageSize") int pageSize
    );

    //获取巡机记录列表
    @GET("webapp/getCordsByTime")
    Observable<BaseBean<PageBean<PatrolRecordListBean>>> getPatrolRecordList(
            @Query("startTime") long startTime,
            @Query("endTime") long endTime,
            @Query("pageNum") int pageNum,
            @Query("pageSize") int pageSize
    );


    //获取巡机记录详情
    @GET("webapp/getWebCords")
    Observable<BaseBean<List<PatrolRecordDetailBean>>> getPatrolRecordDetail(
            @Query("recordid") int recordId
    );

    //获取链接资料
    @GET("webapp/webStationmaterials")
    Observable<BaseBean<PageBean<WorkInfoBean>>> getWebInfo(
            @Query("materialname") String searchText,
            @Query("materialtype") int type,
            @Query("subtype") int subtype,
            @Query("equipmenttypekey") String deviceType,
            @Query("equipmentkey") String deviceId,
            @Query("pageNum") int pageNum,
            @Query("pageSize") int pageSize
    );
}